﻿using System;
using System.Web.Mvc;

class GenericBinder : IModelBinder
{
    #region IModelBinder Members

    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
        var instance = Activator.CreateInstance(bindingContext.ModelType);
        foreach (var prop in bindingContext.ModelType.GetProperties())
        {
            prop.SetValue(instance,
                    controllerContext.HttpContext.Request
                                    .Form[prop.Name.ToLower()],
                    null);
        }
        return instance;

    }

    #endregion
}